<template>
  <view>
    <button @click="request">request</button>
  </view>
</template>

<script>
export default {
  methods: {
    request () {
      return new Promise((resolve, reject) => {
        uni.request({
          url: 'https://unidemo.dcloud.net.cn/ajax/echo/text',
          data: {
            test: 'test'
          },
          success (res) {
            console.log(res)
            resolve(res)
          },
          fail (err) {
            console.error(err)
            reject(err)
          }
        })
      })
    }
  }
}
</script>

<style>
</style>
